package com.coinland.study.view.download;


import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * 类描述: 拦截器
 * 创建人:  shenZ
 * 创建时间: 2020/4/14
 * 联系方式: 252079249@qq.com
 * 修改时间: 2020/4/14
 */
public class JsDownloadInterceptor implements Interceptor {
    private JsDownloadListener downloadListener;

    public JsDownloadInterceptor(JsDownloadListener downloadListener) {
        this.downloadListener = downloadListener;
    }

    @Override
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());
        return response.newBuilder().body(
                new JsResponseBody(response.body(), downloadListener)).build();
    }
}
